﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _6_Decorator
{
    /*
     抽象的对象，对它进行职责添加
     需要装饰的对象
         */
    public class Persion
    {
        public string name;
        public Persion() { }
        public Persion(string name)
        {
            this.name = name;
        }

        public virtual void Show()
        {
            Console.WriteLine("装扮的{0}",name);
        }
    }

    /*需要装饰的对象进行装饰者模式封装*/
    public class Finery : Persion
    {
        //装饰的对象
        protected Persion component;

        /*对对象进行装饰*/
        public void SetComponent(Persion component)
        {
            this.component = component;
        }
        /*装饰者的装饰和调用顺序有关系*/
        public override void Show()
        {
            if (component != null)
            {
                component.Show();
            }
        }
    }

    public class TShirts : Finery
    {
        /*每一个装饰的逻辑*/
        public override void Show()
        {
            base.Show();
            Console.WriteLine("T桖");
        }
    }

    public class BigTrouser:Finery
    {
        public override void Show()
        {
            base.Show();
            Console.WriteLine("大垮裤");
        }
    }
    public class TrackShoes : Finery
    {
        public override void Show()
        {
            base.Show();
            Console.WriteLine("跑鞋");
        }
    }
    public class Jeans : Finery
    {
        public override void Show()
        {
            base.Show();
            Console.WriteLine("牛仔裤");
        }
    }
}
